<template>
  <div class="">
    <div>
      <jbstep :activeStep="activeStep" @backStep="backStep"></jbstep>
    </div>
    <div class="check-con">
      <div class="left-tree">
        <MyTree @backStep="backStep" orgType="1" :activeStep="activeStep"></MyTree>
      </div>
      <div class="right-content">
        <div class="check-info">
          <div v-if="activeStep == 0">
            <Tab000 :orgName="orgName" :orgId="orgId" :examineYear="props.currentRow.examineYear"/>
          </div>
          <div v-if="activeStep == 1">
            <Tab011 />
          </div>
          <div v-else-if="activeStep == 2">
            <Tab021 />
          </div>
          <div v-else-if="activeStep == 3">
            <Tab031 />
          </div>
          <div v-else-if="activeStep == 4">
            <Tab032 />
          </div>
          <div v-else-if="activeStep == 5">
            <Tab033 />
          </div>
          <div v-else-if="activeStep == 6">
            <Tab034 />
          </div>
          <div v-else-if="activeStep == 7">
            <Tab035 />
          </div>
          <div v-else-if="activeStep == 8">
            <Tab041 />
          </div>
          <div v-else-if="activeStep == 9">
            <Tab042 />
          </div>
          <div v-else-if="activeStep == 10">
            <Tab043 />
          </div>
          <div v-else-if="activeStep == 11">
            <Tab051 />
          </div>
          <div v-else-if="activeStep == 12">
            <Tab052 />
          </div>
          <div v-else-if="activeStep == 13">
            <Tab053 />
          </div>
          <div v-else-if="activeStep == 14">
            <Tab054 />
          </div>
          <div v-else-if="activeStep == 15">
            <Tab055 />
          </div>
          <div v-else-if="activeStep == 16">
            <Tab056 />
          </div>
          <div v-else-if="activeStep == 17">
            <Tab057 />
          </div>
          <div v-else-if="activeStep == 18">
            <Tab061 />
          </div>
          <div v-else-if="activeStep == 19">
            <Tab071 />
          </div>
          <div v-else-if="activeStep == 20">
            <Tab0151 />
          </div>
          <div v-else-if="activeStep == 21">
            <Tab0161 />
          </div>
          <div v-else-if="activeStep == 22">
            <Tab0171 />
          </div>
          <div v-else-if="activeStep == 23">
            <Tab0172 />
          </div>
        </div>
      </div>
    </div>

    <div style="margin-top: 30px; text-align: center">
      <el-button  @click="changeStep('prev')">上一步</el-button>
      <el-button @click="changeStep('next')">下一步</el-button>
      <el-button v-if="showBtn" type="primary" @click="toSubmit()">去审核<i
          class="el-icon-s-check el-icon--right"></i></el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, nextTick, inject, provide } from 'vue'
import APTMethods from '@/api/yearCheck/stOrg'
import jbstep from './step.vue'
import MyTree from '../../../components/myTree.vue'
import Tab000 from './checkItem/tab000.vue' //封面
import Tab011 from './checkItem/tab011.vue' //基础信息
import Tab021 from './checkItem/tab021.vue' //负责人信息
//内部建设
import Tab031 from './checkItem/tab031.vue' //年度登记、备案
import Tab032 from './checkItem/tab032.vue' //本年度会议及换届情况
import Tab033 from './checkItem/tab033.vue' //内部管理情况
import Tab034 from './checkItem/tab034.vue' //机构设置情况
import Tab035 from './checkItem/tab035.vue' //党建工作
//财务会计报告
import Tab041 from './checkItem/tab041.vue' //资产负债表
import Tab042 from './checkItem/tab042.vue' //业务活动表
import Tab043 from './checkItem/tab043.vue' //现金流量表
//业务活动情况
import Tab051 from './checkItem/tab051.vue' //年度总结/计划
import Tab052 from './checkItem/tab052.vue' //相关收支、职能和本年度举办重大业务活动情况
import Tab053 from './checkItem/tab053.vue' //接受捐赠资助和使用情况
import Tab054 from './checkItem/tab054.vue' //举办公益慈善活动情况、公益慈善活动支出
import Tab055 from './checkItem/tab055.vue' //本年度举办或参与研讨、展览、培训、评比达标表彰等活动的情况

import Tab056 from './checkItem/tab056.vue' //支援和计划支援西藏昌都建设
import Tab057 from './checkItem/tab057.vue' //参与和计划乡村振兴工作情况

//其他需要说明的情况
import Tab061 from './checkItem/tab061.vue' //其它需要说明的情况

//接受检查监督
import Tab071 from './checkItem/tab071.vue' //接受监督检查情况
//
import Tab0141 from './checkItem/tab0141.vue' //上年度整改情况
import Tab0151 from './checkItem/tab0151.vue' //年检审核意见
import Tab0161 from './checkItem/tab0161.vue' //承接政府购买
import Tab0171 from './checkItem/tab0171.vue' //附件材料
import Tab0172 from '@/views/yearCheck/wFCheck/components/checkST/checkItem/tab0172.vue' //理事监事情况
import { ElMessage, ElMessageBox } from 'element-plus'
import { resolve } from '@antv/x6/lib/registry/node-anchor/util'

defineOptions({
  name: 'logManagement'
})

const emit = defineEmits(['openResult'])
//父组件对子组件提供
// provide('backStep', { backStep });
const props = defineProps({
  currentRow: {
    type: Object,
    default: {}
  },
  showBtn: {
    type: Boolean,
    default: true
  }
})

const activeStep = ref(0)
const textValue = ref('')

const orgId = ref('')
const orgName = ref('')
orgId.value = props.currentRow.creditCode
orgName.value = props.currentRow.organizationBaseName
const getDetailInfo = () => {
  const { id, organizationType } = props.currentRow
  let mark = activeStep.value - 0;
  if(mark == 23){
    mark = 25;
  }
  return new Promise((resolve, reject) => {
    APTMethods.getSTInfoByPage({
      id,
      organizationType,
      pageNumberMark: mark  //页码
    }).then((res) => {
      resolve(res)
    })
  })
}

// 提供方法给子组件
provide('getDetailInfo', { getDetailInfo });


// 搜索
const params = ref<any>({
  typeId: 1
})
const changeStep = (step) => {
  if (textValue.value) {
    saveNote().then(() => {
      activeStep.value =
        step === 'prev'
          ? activeStep.value == 0
            ? 0
            : --activeStep.value
          : activeStep.value == 23
            ? 23
            : ++activeStep.value
    })
  } else {
    activeStep.value =
      step === 'prev'
        ? activeStep.value == 0
          ? 0
          : --activeStep.value
        : activeStep.value == 23
          ? 23
          : ++activeStep.value
  }
}
const nextStep = () => {
  activeStep.value = activeStep.value == 19 ? 19 : ++activeStep.value
  if (textValue.value)
    saveNote().then(() => {
      searchNote()
    })
  else searchNote()
}
const backStep = (index) => {
  activeStep.value = index
}
//保存批注
const saveNote = () => {
  return new Promise<void>((resolve, reject) => {
    ElMessage({
      type: 'success',
      message: '批注保存成功'
    })
    resolve()
  })
}
//切换查询批注
const searchNote = () => {
  setTimeout(() => {
    textValue.value = '123131'
  }, 1000)
}

const toSubmit = () => {
  emit('openResult')
}
</script>
<style>
::v-deep .el-dialog {
  margin-bottom: 0;
}

::v-deep .el-dialog__body {
  padding-top: 0 !important;
}

table.m-table {
  border-spacing: 0px;
  width: 100%;
  border-top: 1px solid #999;
  border-left: 1px solid #999;
  color: #000;

  thead {
    background: #f0f7fc;
    color: rgb(37, 43, 53);

    th {
      border-right: 1px solid #999;
      border-bottom: 1px solid #999;
      text-align: center;
      height: 32px;
    }
  }


  td {
    height: 32px;
    border-right: 1px solid #999;
    border-bottom: 1px solid #999;
    text-align: center;

    &.td-head {
      background: #f0f7fc;
    }
  }

}
</style>
<style lang="scss" scoped>
//隐藏滚轮
::v-deep .el-switch.is-disabled {
  opacity: 1;
}

::v-deep .el-tree-node__content {
  font-size: 12px;
}

::v-deep .el-descriptions__title {
  margin-top: 15px;
}

.check-con {
  width: 100%;
  height: 600px;
  // padding: 0 50px;
  overflow: auto;
  box-sizing: border-box;
  display: flex;

  ::-webkit-scrollbar {
    width: 0;
  }

  //将宽度设为0，滚动条就会隐藏。
  ::-webkit-scrollbar {
    display: none;
  }

  .left-tree {
    width: 280px;
    padding: 20px;
    padding-left: 10px;
    padding-right: 10px;
    margin-right: 10px;
    font-size: 12px;
    box-sizing: border-box;
    height: 600px;
    overflow: auto;
    border: 1px solid #eee;
  }

  .right-content {
    flex: 1;
    height: 600px;
    overflow: auto;
    padding-bottom: 10px;
    box-sizing: border-box;
  }

  .check-info {
    flex: 1;
    padding-right: 20px;
    color: #000;

    >div {
      transition: all 0.5s ease-in-out;
    }
  }
}

.msg-tip {
  padding: 20px 0;
  color: #000;

  font-family: '微软雅黑';
}
</style>
